package com.dtkavin.threads;

/**
 * Created by john on 10/2/16.
 */
public class CreateThread {

    class MyThread extends  Thread{
        @Override
        public void run() {
            System.out.println("create thread and run by : myThread");
        }
    }

    /**
     * 通过Thread创建线程，没有解耦，不推荐
     */
    public void createThreadByThread(){
        MyThread myThread=new MyThread();
        myThread.start();
    }

    class MyRunnable implements Runnable{
        public void run() {
            System.out.println("create thread and run by : My Runnable");
        }
    }

    public void createThreadByRunnable(){
        new Thread(new MyRunnable()).start();
    }
}
